//
//  TXPCacheFile.m
//  StayAwhile
//
//  Created by dllo on 16/2/25.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TXPCacheFile.h"

@implementation TXPCacheFile

+ (NSString *)createFilePathFromDocumentWithFolders:(NSArray<NSString *> *)folders fileName:(NSString *)fileName{
    NSString *document = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    NSString *filePath = [NSString stringWithFormat:@"%@", document];
    for (NSString *folder in folders) {
        filePath = [filePath stringByAppendingPathComponent:folder];
        
    }
    [[NSFileManager defaultManager] createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil];
    filePath = [filePath stringByAppendingPathComponent:fileName];
    return filePath;
}

+ (BOOL)saveDataOnLocal:(NSData *)data localPath:(NSString *)path{
    return [data writeToFile:path atomically:YES];
}


@end
